package com.atguigu.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public class OrderConfirmVo {

    @Getter
    @Setter
    //收货人信息
    private List<MemberReceiveVo> memberReceiveVoList;
    @Getter
    @Setter
    //商品列表信息
    private List<ProductItem> productItemList;
    @Getter
    @Setter
    //发票信息
    //优惠信息(使用积分)
    private Integer integration;

    //库存的Map
    @Setter
    @Getter
    private Map<Long, Boolean> stockMap;


    //总额
    //应付金额
    private BigDecimal payAmt;

    public BigDecimal getTotal() {
        BigDecimal totalAmt = new BigDecimal("0");
        if (productItemList.size() > 0 && productItemList != null) {
            for (ProductItem productItem : productItemList) {

                BigDecimal price = productItem.getPrice().multiply(new BigDecimal(productItem.getCount()));
                totalAmt = totalAmt.add(price);
            }
        }
        return totalAmt;
    }

    public BigDecimal getPayAmt() {
        return getTotal();
    }


    public Integer getCount() {
        Integer count = 0;
        if (productItemList != null && productItemList.size() > 0) {
            for (ProductItem productItem : productItemList) {
                count += productItem.getCount();
            }
        }
        return count;
    }


    //ToDO：防重
    @Getter
    @Setter
    private String orderToken;

}
